package com.demo.server;

import java.util.List;

import org.apache.log4j.Logger;

import com.demo.dao.ICustomDao;
import com.demo.entity.CustomBase;
import com.demo.entity.CustomCrud;
import com.jweb.annotaion.JAutowired;
import com.jweb.annotaion.JMCache;
import com.jweb.annotaion.JParam;
import com.jweb.annotaion.JTransaction;

public class CustomServer {
	@JAutowired
	private ICustomDao customDao;

	Logger log = Logger.getLogger(this.getClass());

	public void delCustomCrudByPId(int id) {
		customDao.delCustomCrudByPId(id);
	}

	public void editCustomBean(CustomBase base) {
		customDao.editCustomBean(base);
	}

	@JMCache(group = "listPayCompant", empty = true)
	public void customCrudAddList(int pid, List<CustomCrud> listAll) {
		customDao.addCustomCrudList(listAll, pid);
	}

	@JTransaction
	@JMCache(group = "listPayCompant", empty = true)
	public void customAdd(CustomBase base, List<CustomCrud> listAll) {
		customDao.addCustomBase(base);
		int pid = base.getId();
		customDao.addCustomCrudList(listAll, pid);
	}

	@JMCache(group = "listPayCompant", key = "id")
	public CustomBase getCustomBase(@JParam("id") int id) {
		return customDao.getCustomBase(id);
	}

	@JMCache(group = "listPayCompant", key = "cacheKey")
	public List<CustomCrud> getCustomCrudList(int pid, int operatType, @JParam("cacheKey") String cacheKey) {
		return customDao.getCustomCrudList(pid, operatType);
	}

}
